# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrzej Giniewicz <gginiu@gmail.com>

pkgname=python2-configparser
pkgver=4.0.2
pkgrel=2
pkgdesc="This library brings the updated configparser from Python 3.5 to Python 2.6-3.5."
arch=('any')
url="https://bitbucket.org/ambv/configparser"
license=('MIT')
depends=('python2-backports')
makedepends=('python2-setuptools')
source=("https://pypi.io/packages/source/c/configparser/configparser-${pkgver}.tar.gz" license)
md5sums=('35926cc4b9133f1f9ca70a1fd2fdf237'
         'f8e5b03556ed846d7681bacd4126f484')

prepare() {
  sed -i -e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" \
    $(find "$srcdir"/configparser-${pkgver} -name '*.py')
}

build() {
  cd configparser-$pkgver
  python2 setup.py build
}

package() {
  cd configparser-$pkgver
  python2 setup.py install --prefix=/usr --root="$pkgdir" --optimize=1

  rm "$pkgdir"/usr/lib/python2.7/site-packages/backports/__init__.py{,c,o}

  install -D "$srcdir"/license "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
